<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="//at.alicdn.com/t/font_2107594_ukp7a5lmzw8.css">
    <title>Document</title>
    <style>
        #box{
            width: 400px;
            margin: 100px auto;
        }
        #box input{
            width: 200px;
            height: 30px;
            line-height: 5px;
            border: 0;
            border-bottom: 1px solid #ccc;
            outline: none;
        }
        #box p{
            color: #999;
            display: inline-block;
            height: 18px;
            font-size: 12px;
        }
    </style>
</head>
<body>
    <div id="box">
        <input type="password">
        <p class="iconfont icon-weibiaoti-"> 请输入6~16位密码</p>
        <script>
            var input = document.getElementById('box').querySelector('input');
            var p = document.getElementById('box').querySelector('p');
            input.onblur = function(){
                if(this.value.length<6 || this.value.length>16){
                    p.className = 'iconfont icon-cross';
                    p.style.color = 'red';
                }else{
                    p.className = 'iconfont icon-gou';
                    p.style.color = 'yellow';
                    p.innerHTML = '输入正确！';
                }
            }
        </script>
    </div>
</body>
</html>